<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加品牌</title>
    <script src="js/vue.js"></script>
    <script src="js/axios-0.18.0.js"></script>
</head>
<body>
<div id="app">
    <h3>添加品牌</h3>
    <form action="" method="post">
        品牌名称: <input id="brandName" name="brandName" v-model="brand.brandName"><br>
        企业名称: <input id="companyName" name="companyName" v-model="brand.companyName"><br>
        排序: <input id="ordered" name="ordered" v-model="brand.ordered"><br>
        描述信息: <textarea rows="5" cols="20" id="description" name="description" v-model="brand.description"></textarea><br>
        状态:
        <input type="radio" name="status" value="0" v-model="brand.status">禁用
        <input type="radio" name="status" value="1" v-model="brand.status">启用<br>
        <input type="button" id="btn" value="提交" @click="submitForm">
    </form>
</div>



<script>
    new Vue({
        el:"#app",
        data(){
            return{
                brand:{}
            }
        },
        methods:{
            submitForm(){
                //发送ajax请求
                let _this = this;
                axios({
                    method: "post",
                    url: "http://localhost:8080/web_22_vueCase/addServlet",
                    data: _this.brand
                }).then(function (resp){
                    //判断响应数据是否为success
                    if(resp.data == "success"){
                        location.href = "http://localhost:8080/web_22_vueCase/brand.html";
                    }
                })
            }
        }
    });
</script>

</body>
</html>